public class ArrayUtil {

    //私有化构造方法：为了不让外界创造他的对象
    private ArrayUtil(){}

    //遍历，输出集合
    public static String ptintArr(int[] arr){
        StringBuilder sb=new StringBuilder();
        sb.append("[");
        for (int i = 0; i < arr.length; i++) {
            if(i== arr.length-1){
                sb.append(arr[i]);
            }else {
                sb.append(arr[i]).append(",");
            }
        }
        sb.append("]");
        return sb.toString();
    }


    //求平均值
    public static double getAverage(double[] arr){
        double sum=0;
        for (int i = 0; i < arr.length; i++) {
            sum=sum+arr[i];
        }
        return  sum/arr.length;
    }
}
